package com.dd.stack.redis.service.inner.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

/**
 * @Author liuxianmeng
 * @CreateTime 2025/1/30 17:05
 * @Description 此服务来发布消息到Redis频道
 */
@Slf4j
@Service
public class RedisPubSubServiceImpl {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    public void publishOrder(String orderData) {
        // 发布消息到频道
        stringRedisTemplate.convertAndSend("orderChannel", orderData);
        log.info("Order data published: " + orderData);
    }
}
